<?php

include_once("includes/Database.php");
include_once ("objects/Result.php");

class HumanModel {

	// Get all Agenda
	public function getTourguiderList()
	{
		// create an instance of the Database class and call it $db
		$db = new Database();
		//connect database
		$db->connect();
		// do a query to retrieve multiple records
		$query = "SELECT identify,name,username,age,phone,image,latitude,longitude,tourcode,UUID,type FROM humanentry";
		// query the database
		$db->select($query);
		// get result
		$results = $db->getResult();
		// disconect database
		$db->disconnect();
		//return result
		return $results;
	}

	//Get Agenda List By id
	public function getTourguiderById($tourguiderId)
	{
		// create an instance of the Database class and call it $db
		$db = new Database();
		//connect database
		$db->connect();
		// do a query to retrieve multiple records
		$query = "SELECT identify,name,username,age,phone,image,latitude,longitude,tourcode,UUID,type FROM humanentry WHERE identify = $tourguiderId";
		// query the database
		$db->select($query);
		// get result
		$results = $db->getResult();
		// disconect database
		$db->disconnect();
		//return result
		return $results;
	}

	public function checkLogin($username,$password)
	{
		// create an instance of the Database class and call it $db
		$db = new Database();
		//connect database
		$db->connect();
		// do a query to retrieve multiple records
		$query = "SELECT identify FROM humanentry WHERE username ='$username' AND password = '$password' AND type = 1";
		// query the database
		$db->select($query);
		// get result
		$results = $db->getResult();
		// disconect database
		$db->disconnect();

		//check login
		if($results!=null){
			$results = "true";
		}
		else{
			$results = "false";
		}
		$results = new Result($results);
		//return result
		return $results;
	}
// 	$query = "INSERT INTO usaperfe_vu.humanentry (name,username ,password ,age ,phone ,image,latitude ,longitude ,tourcode ,UUID ,type)VALUES ('$name', '$username', '$password', '$age', '$phone', $imagelink , $latitude , $longitude , '$tourcode','$uuid',$type');
	public  function inserthuman($name,$username, $password,$age,$phone,$imagelink,$latitude,$longitude,$tourcode,$uuid,$type)
	{
		// create an instance of the Database class and call it $db
		$db = new Database();
		//connect database
		$db->connect();
		
		$query = "INSERT INTO humanentry (name,username ,password ,age ,phone ,image,latitude ,longitude ,tourcode ,UUID ,type)
		VALUES ('$name', '$username', '$password', '$age', '$phone', '$imagelink' , '$latitude' , '$longitude' , '$tourcode','$uuid','$type')";

		$results = $db->insert($query);
		$db->disconnect(); 
		if($results!=null)
		{
			return new Result($results);
		}
		else
		{
			$results = "false";
			return new Result($results);
		}
	}
}

?>